<?php
/**
 * Converts from ref xml into rdfa
 *
 * @copyright &copy; 2009 The Open University
 * @author j.platts@open.ac.uk
 * @author Author_Name_2@open.ac.uk
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package local/references/convert/bibo package_name
 */


class references_convert_bibo_rdfa extends format{


    public function __construct(){

    }

    public static function can_import(){
        return false;
    }

    public static function can_export(){
        return true;
    }

    //no import
    public function import(&$data){

    }

    /**
     * Displays html that can be copied by end-user and pasted into an external website or moodle tool
     * @see local/references/convert/format#export()
     */
    public function export(&$data,$options){
        
        //if $data is a string turn into xml dom
       if(is_string(&$data)){
            $data=parent::string_to_dom(&$data);
        }

        //check is DOMDocument
        if(!$data instanceOf DOMDocument){
            return false;
        }

        //Transform our refxml data into rdfa using xslt
        // Load XSL template
        $xsl = new DOMDocument();
        if(!$xsl->load(dirname(__FILE__).'/xml2rdfa.xsl')){
            return false;
        }

        // Create new XSLTProcessor
        $xslt = new XSLTProcessor();
        // Load stylesheet
        if(!$xslt->importStylesheet($xsl)){
            return false;
        }
        
        //sorting
        /*$xslt->setParameter('','sortby',$sorting);
        if($sorting=='date'||$sorting=='created'||$sorting=='modified'){
            $xslt->setParameter('','sorttype','number');
        }*/
        
        $results = $xslt->transformToDoc(&$data);

        $result = preg_replace('/<!DOCTYPE[^>]*>/',' ',$results->saveHTML());
        
        print($result);
        
    }

    public static function is_format(&$data){
        return false;
    }
}

?>